angular.module('starter')
.controller('onedaydetailCtrl', function($scope,$ionicScrollDelegate,$state,$stateParams,meilvFac,$timeout) {
 	$scope.contentScroll = function() {
    $ionicScrollDelegate.scrollTop(true);
  	};
  	$scope.getScrollPosition = function(){
  		var winH=$(window).height();
	   if($ionicScrollDelegate.getScrollPosition().top>winH-500)
	   	{
	   		$(".scroll-top").fadeIn();
		}
		else{
			$(".scroll-top").fadeOut();
		}
	}

	$scope.initDetail=function(){
		var article_id=$stateParams.id;
		meilvFac.articleshow.index(
			{article_id:article_id},
			function(data)
				{
					$scope.detailInfo=data.info[0];
				},
			function(data)
				{
					alert(data.data.info);
				}
		);
	}

	$scope.userCollection=function(id){
        meilvFac.collection.collectionadd(
            {article_id:id},
            function(data){
                $scope.initDetail();
            },
            function(data){
                alert(data.data.info);
            }
        )
    }

  $scope.submit = function(){
    $timeout(function(){
      $state.go("tab.orderstepone",{id:$scope.detailInfo.id},{reload:true});
    },1);
    
  };
})